﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Medianamik.Core.Resources;
using NUnit.Framework;
using Moq;
using Medianamik.Core.Interfaces;

namespace Medianamik.Tests.Unit.Medianamik.Core.Resources
{
    [TestFixture]
    public class MedianamikAssemblyCollectionTest
    {
        public MedianamikAssemblyCollection AssemblyCollection
        {
            get;
            set;
        }
        public IMedianamikAssembly Assembly1
        {
            get;
            set;
        }
        public IMedianamikAssembly Assembly2
        {
            get;
            set;
        }

        public IMedianamikAssembly Assembly3
        {
            get;
            set;
        }

        [SetUp]
        public void Init()
        {
            var mock1 = new Mock<IMedianamikAssembly>( );
            mock1.SetupGet(m=>m.Depth ).Returns(0);

            Assembly1 = mock1.Object;

            var mock2 = new Mock<IMedianamikAssembly>();
            mock2.SetupGet(m=>m.Depth ).Returns(1);

            Assembly2 = mock2.Object ;

            var mock3 = new Mock<IMedianamikAssembly>();
            mock3.SetupGet(m=>m.Depth ).Returns(2);

            Assembly3 = mock3.Object ;

            AssemblyCollection = new MedianamikAssemblyCollection( new IMedianamikAssembly[] 
                                                                       {
                                                                           Assembly1, Assembly3, Assembly2   
                                                                       });
            
        }
        [Test]
        public void The_collection_should_be_sorted_by_MedianamikAssembly_depth_desc()
        {
            Assert.AreEqual(AssemblyCollection.First(), Assembly3 );
            Assert.AreEqual(AssemblyCollection.Last (), Assembly1);
        }
                
    }
}